import React from 'react'
import { TreeNode } from '@designable/core'
import { transformToSchema } from '@designable/formily-transformer'
import { SchemaApp } from '../../src/customComponents/SchemaApp'

export interface IPreviewWidgetProps {
  tree: TreeNode
}

export const PreviewWidget: React.FC<IPreviewWidgetProps> = (props) => {
  const { page, schema } = transformToSchema(props.tree)
  return <SchemaApp pageSchema={{ formProps: page, schema }} />
}
